using System;
using System.Diagnostics;
using System.Windows.Forms;
namespace com.haopintui.util
{
	public class ProcessesUtil
	{
		public void kill(string processName)
		{
			processName = processName.Replace(".exe", "");
			Process[] processes = Process.GetProcesses();
			for (int i = 0; i < processes.Length; i++)
			{
				Process process = processes[i];
				if (processName.Equals(process.ProcessName))
				{
					process.Kill();
					return;
				}
			}
		}
		public static bool isExist(string processName, int version)
		{
			processName = processName.Replace(".exe", "");
			Process[] processes = Process.GetProcesses();
			for (int i = 0; i < processes.Length; i++)
			{
				Process process = processes[i];
				if (processName.Equals(process.ProcessName))
				{
					return true;
				}
			}
			return false;
		}
		public static void check_Process()
		{
			if (Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName).Length > 1)
			{
				MessageBox.Show("程序已经运行！", "消息", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				Environment.Exit(Environment.ExitCode);
			}
		}
	}
}
